import lejos.nxt.*;
import lejos.robotics.navigation.Pilot;
import lejos.robotics.navigation.TachoPilot;

/**
 * Trace a square 
 * @author Roger
 */
public class square
{
	static float inchToCm =2.5171f; 
    Pilot pilot ;
    public void  drawSquare(float length, int veelhoek)
    {
    	
    	int graden = (veelhoek-2)*180;
    	pilot.setTurnSpeed(70);
    	pilot.setMoveSpeed(5f);
        for(int i = 0; i<veelhoek; i++)
        {
        	
            pilot.travel(length);
            pilot.rotate(180-graden/veelhoek); 
            pilot.arc(15f);
        }
    }
    public void  turn()
    {
            pilot.rotate(180);
        
    }
    
    public void twoMeters()
    {
    	pilot.travel(100f/inchToCm);
    }
    
    public static void main(String[] args)
    {
        square sq = new square();
        sq.pilot = new TachoPilot(2.2f, 4.233f, Motor.A, Motor.C, true);

        sq.drawSquare(-200f/inchToCm, 4);
        
        //sq.turn();
        //sq.twoMeters();
    }
}


